package com.qihe.reviewj2se;

class HelloWorld {
	public static void main(String[] args) {
		HelloEarth he = HelloEarth.GetInstance();
		he.setGreeting("earth");
		System.out.println("HelloWorld.main() say hello " + he.getGreeting() + "!");
	}
}
class HelloEarth {
	//singleton
	private static HelloEarth he = new HelloEarth();
	private HelloEarth(){};
	public static HelloEarth GetInstance() {
		if(he == null) {
			return new HelloEarth();
		} else {
			return he;
		}
	}
	
	private String greeting;

	public String getGreeting() {
		return greeting;
	}

	public void setGreeting(String greeting) {
		this.greeting = greeting;
	}
	
}
